<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> -->
  <xsl:output omit-xml-declaration="no" indent="yes"/>

<xsl:template match="viewentries">
  <viewentries>
    <!--<xsl:apply-templates mode="header"/>  -->

<xsl:apply-templates/>

  </viewentries>
</xsl:template>
  
<xsl:template match="viewentry">
<!--Each viewentry translates to a row in the table -->
  <xsl:element name ="viewentry">
<xsl:apply-templates/>
    </xsl:element>
</xsl:template>

<xsl:template match="entrydata">
<!-- each entry data is a column in the table -->


  <xsl:element name ="{@name}">
    <xsl:apply-templates/>
  </xsl:element> 
  

</xsl:template>

<!-- Here are the 3 data types in single value, number and date time are just copied, would need some facelift -->
<xsl:template match="text">
<!--copy the column value -->
<xsl:value-of select="."/> 
</xsl:template>

<xsl:template match="number">
<!--copy the column value -->
<xsl:value-of select="."/>
</xsl:template>

<xsl:template match="datetime">
<!--copy the column value -->
<xsl:value-of select="."/>
</xsl:template>

<!-- the 3 list types -->
<xsl:template match="textlist">
<!--display as ordered list -->

<xsl:apply-templates/>

</xsl:template>

<xsl:template match="numberlist">
<!--display as unordered list -->
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>

<xsl:template match="datetimelist">
<!--display as unordered list -->
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>

<!-- Here are the 3 data types in multi value, number and date time are just copied, would need some facelift -->
<xsl:template match="textlist/text">
<!--copy the column value -->
<li>
<xsl:value-of select="."/>
</li>
</xsl:template>

<xsl:template match="numberlist/number">
<!--copy the column value -->
<li>
<xsl:value-of select="."/>
</li>
</xsl:template>

<xsl:template match="datetimelist/datetime">
<!--copy the column value -->
<li>
<xsl:value-of select="."/>
</li>
</xsl:template>

<!-- Here are the templates to create the table header -->
<xsl:template match="viewentry[position()=1]" mode="header">

<tr>
<xsl:apply-templates mode="header"/>
</tr>
</xsl:template>

<xsl:template match="entrydata" mode="header">
<th>
<xsl:value-of select="@name"/>
</th>
</xsl:template>

<!-- With the following statement we make sure, that NO unwanted elements are copied into the output -->
<xsl:template match="*" mode="header"/>

<xsl:template match="*"/>
</xsl:stylesheet>


